问题列表 - 第317970页

3
推荐指数
1
解决办法
80
查看次数

删除对象最上面的键?

是否可以压平或移除对象最上面的键?例如:

const obj = {
  page: {
    title: 'x',
    images: {
      0: {
        src: '...'
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

所以我可以得到:

{
  title: 'x',
  images: {
    0: {
      src: '...'
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我尝试过,map但结果不是我想要的:

const obj = {
  page: {
    title: 'x',
    images: {
      0: {
        src: '...'
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

javascript

2
推荐指数
1
解决办法
91
查看次数

为什么 C# 12 主构造函数以相反的顺序执行?

为什么C# 12 中的主构造函数以相反的顺序执行?

\n

至少可以说这是一个突破性的改变......

\n

例子:

\n
namespace Whatever;\n\n[TestClass]\npublic class UnitTestTemp\n{\n    [TestMethod]\n    public void TestMethod1() // PASS // is expected, 1st is 1, 2nd is 2\n    {\n        using var stream = new MemoryStream(new byte[] { 1, 2, 3, 4 });\n\n        var classicDerived = new ClassicDerived(stream);\n\n        Console.WriteLine(classicDerived.Value1);\n        Console.WriteLine(classicDerived.Value2);\n\n        Assert.AreEqual(1, classicDerived.Value1);\n        Assert.AreEqual(2, classicDerived.Value2);\n    }\n\n    [TestMethod]\n    public void TestMethod2() // FAIL // is opposite, 1st is 2, 2nd is 1\n    {\n        using var stream = new MemoryStream(new byte[] { …
Run Code Online (Sandbox Code Playgroud)

c# constructor primary-constructor .net-8.0 c#-12.0

12
推荐指数
2
解决办法
465
查看次数

(已解决)未解决的参考:onCreate 函数 JetPack Compose 中的enableEdgeToEdge

我正在学习 Android 基础课程,提供的解决方案代码在 MainActivity 中有enableEdgeToEdge()函数调用onCreate()。当我使用这行代码时,出现Unresolved reference: enableEdgeToEdge错误。

尽管尝试了多次导入并在互联网上查找该问题,但仍找不到解决方案。有想法该怎么解决这个吗?

GitHub 上提供的代码:https://github.com/alghe-global/Kotlin/blob/4a25e707d4efc3edf09c7f637635adec8f6e876b/AndroidBasicsCourse/TipTime/app/src/main/java/com/example/tiptime/MainActivity.kt#L36

注意来自Google的解决方案代码可在@ https://github.com/google-developer-training/basic-android-kotlin-compose-training-tip-calculator/blob/29dddab0d5d911f1607bc5602249f89012f4d45e/app/src/main/java/com/示例/tiptime/MainActivity.kt#L54

尝试import androidx.activity.enableEdgeToEdge并调用enableEdgeToEdge()会在导入和函数调用上onCreate(...)出现错误Unresolved reference: enableEdgeToEdgeenableEdgeToEdgeenableEdgeToEdge()


添加implementation("androidx.activity:activity:1.8.1")到build.gradle.kts(Module:app) 允许我使用enableEdgeToEdge

android-jetpack-compose

5
推荐指数
1
解决办法
1271
查看次数

是否有可能将某个值提升到 Grammar TOP?

我有这个 raku 语法:

#!/usr/bin/env raku
use v6.d;

use Grammar::Tracer;

grammar Grammar {
    token TOP {
          <city>      \v
          <state-zip> \v?
    }
    token city {
        ^^ \V* $$
    }
    token state-zip {
        ^^ <state> <.ws>? <zipcode> $$    #<.ws> is [\h* | \v]
    }
    token state {
        \w \w
    }
    token zipcode {
        \d ** 5
    }
}

class Actions {
    method TOP($/) {
        #works
        say "city is ",    $_ with $<city>.made;
        say "state is ",   $_ with $<state-zip><state>.made;
        say "zipcode is ", …
Run Code Online (Sandbox Code Playgroud)

grammar parsing raku

5
推荐指数
1
解决办法
136
查看次数

多切片导丝提交

只是想知道为什么提交交易将具有具有多个切片的有效实体。任何 Guidewire 文档的链接都会有所帮助。

通过更改提交的生效日期并多次引用,在较低环境中尝试了各种场景,但仍然无法重现。但我们发生了一起事件,因此正在寻找意见。

guidewire

-1
推荐指数
1
解决办法
124
查看次数

使用构面时,ggplot 颜色条与顶部对齐

我正在使用ggplot包含颜色条的多面图。我想将颜色条缩放到多面图的大小。按照 @AllanCameron 在这篇文章中关于单个图的想法并调整函数以考虑条带大小和图之间的空间,我能够正确计算出图例的大小。因此,无论ncol、panel.spacing.y或 ,图例的大小都被正确指定。strip.text.x。

但是,默认情况下,图例位于两个没有条带的图之间的中心。到目前为止,通过legend.position或调整图例并不能帮助正确指定它。如何将图例与图表顶部(即条带顶部)正确对齐(有关预期输出,请参阅右侧的图)?legend.justification

例子

我仅在右侧图表中将图例对齐到顶部,而没有使用外部图形程序调整大小。因此,虽然左侧图表中的图例高度看起来太小,但实际上尺寸还不错。

library(ggplot2)

df <- expand.grid(
  x = c(1, 2, 3),
  y = c(1, 2, 3),
  g = c("one", "two", "three", "four")
)

set.seed(1)
df$v <- runif(nrow(df), min = 0, max = 1)

make_fullsize <- function() structure("", class = "fullsizebar")

ggplot_add.fullsizebar <- function(obj, g, name = "fullsizebar") {
  h <- ggplotGrob(g)$heights
  panel <- which(grid::unitType(h) == "null")
  panel_height <- unit(1, "npc") - …
Run Code Online (Sandbox Code Playgroud)

r facet ggplot2

1
推荐指数
1
解决办法
147
查看次数

为什么 std::cell::Ref 不使用引用而不是 NonNull?

Rust 中的结构体std::cell::Ref定义如下:

pub struct Ref<'b, T: ?Sized + 'b> {
    // NB: we use a pointer instead of `&'b T` to avoid `noalias` violations, because a
    // `Ref` argument doesn't hold immutability for its whole scope, only until it drops.
    // `NonNull` is also covariant over `T`, just like we would have with `&T`.
    value: NonNull<T>,
    borrow: BorrowRef<'b>,
}
Run Code Online (Sandbox Code Playgroud)

评论// NB(我假设 Nota bene / Nasty Bug 或其他什么?)暗示以下定义不起作用,因为这会违反noalias(它们是否意味着后端的 LLVM 属性?):

pub struct Ref2<'b, T: ?Sized …
Run Code Online (Sandbox Code Playgroud)

unsafe language-lawyer rust refcell

6
推荐指数
1
解决办法
147
查看次数

在 C# 正则表达式中,如何优化匹配字符子序列

给定一个字符串输入,我想使用 C# 正则表达式来匹配部分字符序列,但按顺序从头开始。

以下输入将全部匹配:

  • t
  • tr
  • tru
  • true

以下输入将不匹配:

  • tu
  • tre
  • tuer
  • rue

我想出了几个解决方案,但我想要一个更优雅的解决方案。

解决方案一:

^(t|tr|tru|true|f|fa|fal|fals|false)$
Run Code Online (Sandbox Code Playgroud)

解决方案2:

^(t(r(u(e)?)?)?|f(a(l(s(e)?)?)?)?)$
Run Code Online (Sandbox Code Playgroud)

c# regex

0
推荐指数
1
解决办法
69
查看次数

SQL脚本有时有效,有时无效;出了什么问题?

有谁知道什么可能会导致这段代码有时运行正常,有时抛出错误消息?

drop table if exists mapping_rules;

create table mapping_rules
(
    claimant_type char(50),
    tpd_flag char(10),
    tpi_flag char(10),
    mapped_claim_type_1_high char(30),
    mapped_claim_type_2_detailed char(30),
    mapped_claim_type_3_high_ex_recovery char(30),
    mapped_claim_type_4_detailed_ex_recovery char(30)
);

bulk insert mapping_rules
from '>>>censored-filename<<<.csv'
with (format = 'CSV', firstrow = 2);

-- convert TRUE and FALSE to 1 and 0

alter table mapping_rules
add tpd_flag_2 int,
    tpi_flag_2 int;

update mapping_rules
set tpd_flag_2 = case when (tpd_flag = 'TRUE') then 1 else 0 end,
    tpi_flag_2 = case when (tpi_flag = 'TRUE') then 1 else 0 …
Run Code Online (Sandbox Code Playgroud)

sql sql-server

0
推荐指数
1
解决办法
115
查看次数